home *** CD-ROM | disk | FTP | other *** search
- /* CheckNewMail.rexx
- v 1.5 - 11-Jun-97
-
- This script checks if there are new or unread messages and where they are.
- It requiress reqtools and rexxreqtools libraries.
-
- Changes in 1.5
- - If the value of variable AllowDupl is 'no' then only one instance
- of the script can be running any given time. If the script is
- started while the requester is still open, it quits.
-
- Changes in 1.4
- - Doesn't get confused if some folders have been deleted
-
- This and more than dozen other scripts can be found at
- http://www.utu.fi/~knikulai/ARexx.html
-
- You can also get the latest version of this script by sending a message
- with subject REQUEST to knikulai@utu.fi. In the message body you can
- use commands dir, get <file> and help.
- */
- call addlib('rexxsupport.library',0,-30,0)
- options results
- AllowDupl='no' /* If set to 'no', the script quits if the requester is already open */
- maxfolder=12 /* Set this to the number of folders you have-1*/
- cols=3 /* How many colums of folders in requester */
- wid=17 /* Max displayed width of foldername + message counts*/
- butl=70 /* Maximum length of buttons in characters. Increase this a bit
- if you are using a proportional font. */
- dontquit='OFF' /* If 'on', the requester stays until Done is selected*/
- sunr='YES' /* Search for unread messages too ( yes/no ) */
-
- /* Change these to something you like */
- title='CheckNewMail.rexx'
- new_title='You have new mail in following folders: (new/unread)'
- no_new_title='You have no new mail.'
- unread_title='You have unread mail in following folders:'
- no_unread_title='You have no folders with only unread mail.'
- select_folder='Select folder you want to read next'
- last_button='_Done'
-
- if upper(AllowDupl)='NO' & show('p','CNMport') then exit
- call OpenPort('CNMport')
-
- addlib('rexxreqtools.library',0,-30)
- address 'YAM'
- 'Hide'
-
- GetFolderInfo Number /* Let's remember where we are now */
- orig_fold=result
- GetMailInfo Active
- orig_msg=result
-
- nc=0 /* new-counter */
- uc=0 /* unread-counter */
- NL='0a'x /* newline */
- do f=0 to maxfolder
- if f~=1 & f~=2 then do /* Don't check Outgoing nor Sent */
- SetFolder f
- if rc=0 then do
- GetFolderInfo Name
- fn=result /* Name of the folder */
- GetFolderInfo Max
- n=result /* Number of messages in the folder */
- i=0
- nm=0
- um=0
- do while i<n
- SetMail i
- i=i+1
- GetMailInfo Status
- if result='N' then nm=nm+1 /* New message was found */
- if result='U' & upper(sunr)='YES' then um=um+1/* Unread message was found */
- end /* do while i<n */
- if nm>0 then do /* New messages were found */
- nc=nc+1
- foo= nm ||'/'|| um
- new.nc=left(fn||' ',wid-length(foo), '.') || foo
- newn.nc=f
- end
- else
- if um>0 & upper(sunr)='YES' then do /* New messages were found */
- uc=uc+1
- unread.uc=left(fn||' ', wid-length(um), '.') || um
- unreadn.uc=f
- end
- end /* if rc=0 */
-
- end /* if f~=1 & f`=2 then do */
- end /* do f=0 to maxfolder */
-
- /* Now all folders have been scanned */
- but=''
- bc=0
-
- /* Return to where we were before starting this script */
- 'Show'
- 'SetFolder' orig_fold
- 'SetMail' orig_msg
-
- /* Let's first list new messages */
- if nc>0 then
- rt=new_title
- else
- rt=no_new_title || NL
-
- rt=rt || NL
- do i=1 to nc
- rt=rt || new.i || ' '
- if length(but)+length(word(new.i,1))<butl then do
- but=but || word(new.i,1) || '|'
- bc=bc+1
- butn.bc=newn.i
- end
- if i//cols = 0 then rt=rt || NL
- end
-
- /* Then it's time to list unread messages, if that was asked */
- if upper(sunr)='YES' then do
- if uc>0 then
- rt=rt||NL|| unread_title
- else
- rt=rt||NL|| no_unread_title
- rt=rt || NL
- do i=1 to uc
- rt=rt || unread.i ||' '
- if i//cols = 0 then rt=rt || NL
- if length(but)+length(word(unread.i,1))<butl then do
- but=but || word(unread.i,1) || '|'
- bc=bc+1
- butn.bc=unreadn.i
- end
- end
- end /* if upper(sunr)='YES' */
-
- rt=rt || NL || NL || select_folder
- but=but || last_button
- tags='rtez_defaultresponse=0'
-
- sel=1
-
-
- do until sel=0 | upper(dontquit)='OFF'
- sel=rtezrequest(rt,but,title,tags)
- if sel>0 then address 'YAM' 'SetFolder ' || butn.sel
- end
-